<?php


/*
* Copyright (c) 2008-2016 vip.com, All Rights Reserved.
*
* Powered by com.vip.osp.osp-idlc-2.5.11.
*
*/

namespace com\vip\vlp\service\vop\product;

class DetailData {
	
	static $_TSPEC;
	public $goods = null;
	public $support_services = null;
	public $color = null;
	public $size_table = null;
	public $qa = null;
	
	public function __construct($vals=null){
		
		if (!isset(self::$_TSPEC)){
			
			self::$_TSPEC = array(
			1 => array(
			'var' => 'goods'
			),
			2 => array(
			'var' => 'support_services'
			),
			3 => array(
			'var' => 'color'
			),
			4 => array(
			'var' => 'size_table'
			),
			5 => array(
			'var' => 'qa'
			),
			
			);
			
		}
		
		if (is_array($vals)){
			
			
			if (isset($vals['goods'])){
				
				$this->goods = $vals['goods'];
			}
			
			
			if (isset($vals['support_services'])){
				
				$this->support_services = $vals['support_services'];
			}
			
			
			if (isset($vals['color'])){
				
				$this->color = $vals['color'];
			}
			
			
			if (isset($vals['size_table'])){
				
				$this->size_table = $vals['size_table'];
			}
			
			
			if (isset($vals['qa'])){
				
				$this->qa = $vals['qa'];
			}
			
			
		}
		
	}
	
	
	public function getName(){
		
		return 'DetailData';
	}
	
	public function read($input){
		
		$input->readStructBegin();
		while(true){
			
			$schemeField = $input->readFieldBegin();
			if ($schemeField == null) break;
			$needSkip = true;
			
			
			if ("goods" == $schemeField){
				
				$needSkip = false;
				
				$this->goods = new \com\vip\vlp\service\vop\product\DetailGoods();
				$this->goods->read($input);
				
			}
			
			
			
			
			if ("support_services" == $schemeField){
				
				$needSkip = false;
				
				$this->support_services = array();
				$_size0 = 0;
				$input->readListBegin();
				while(true){
					
					try{
						
						$elem0 = null;
						
						$elem0 = new \com\vip\vlp\service\vop\product\DetailSupportServices();
						$elem0->read($input);
						
						$this->support_services[$_size0++] = $elem0;
					}
					catch(\Exception $e){
						
						break;
					}
				}
				
				$input->readListEnd();
				
			}
			
			
			
			
			if ("color" == $schemeField){
				
				$needSkip = false;
				
				$this->color = array();
				$_size1 = 0;
				$input->readListBegin();
				while(true){
					
					try{
						
						$elem1 = null;
						
						$elem1 = new \com\vip\vlp\service\vop\product\DetailColor();
						$elem1->read($input);
						
						$this->color[$_size1++] = $elem1;
					}
					catch(\Exception $e){
						
						break;
					}
				}
				
				$input->readListEnd();
				
			}
			
			
			
			
			if ("size_table" == $schemeField){
				
				$needSkip = false;
				
				$this->size_table = new \com\vip\vlp\service\vop\product\DetailSizeTable();
				$this->size_table->read($input);
				
			}
			
			
			
			
			if ("qa" == $schemeField){
				
				$needSkip = false;
				
				$this->qa = array();
				$_size2 = 0;
				$input->readListBegin();
				while(true){
					
					try{
						
						$elem2 = null;
						
						$elem2 = new \com\vip\vlp\service\vop\product\QuestionAnswers();
						$elem2->read($input);
						
						$this->qa[$_size2++] = $elem2;
					}
					catch(\Exception $e){
						
						break;
					}
				}
				
				$input->readListEnd();
				
			}
			
			
			
			if($needSkip){
				
				\Osp\Protocol\ProtocolUtil::skip($input);
			}
			
			$input->readFieldEnd();
		}
		
		$input->readStructEnd();
		
		
		
	}
	
	public function write($output){
		
		$xfer = 0;
		$xfer += $output->writeStructBegin();
		
		if($this->goods !== null) {
			
			$xfer += $output->writeFieldBegin('goods');
			
			if (!is_object($this->goods)) {
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$xfer += $this->goods->write($output);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->support_services !== null) {
			
			$xfer += $output->writeFieldBegin('support_services');
			
			if (!is_array($this->support_services)){
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$output->writeListBegin();
			foreach ($this->support_services as $iter0){
				
				
				if (!is_object($iter0)) {
					
					throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
				}
				
				$xfer += $iter0->write($output);
				
			}
			
			$output->writeListEnd();
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->color !== null) {
			
			$xfer += $output->writeFieldBegin('color');
			
			if (!is_array($this->color)){
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$output->writeListBegin();
			foreach ($this->color as $iter0){
				
				
				if (!is_object($iter0)) {
					
					throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
				}
				
				$xfer += $iter0->write($output);
				
			}
			
			$output->writeListEnd();
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->size_table !== null) {
			
			$xfer += $output->writeFieldBegin('size_table');
			
			if (!is_object($this->size_table)) {
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$xfer += $this->size_table->write($output);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->qa !== null) {
			
			$xfer += $output->writeFieldBegin('qa');
			
			if (!is_array($this->qa)){
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$output->writeListBegin();
			foreach ($this->qa as $iter0){
				
				
				if (!is_object($iter0)) {
					
					throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
				}
				
				$xfer += $iter0->write($output);
				
			}
			
			$output->writeListEnd();
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		$xfer += $output->writeFieldStop();
		$xfer += $output->writeStructEnd();
		return $xfer;
	}
	
}

?>